<form id="brandForm" action="index.php?app=openapi&ctl=admin_setting&act=save"  method="post">
<input type="hidden" name="s_id" value="<{$settingInfo.s_id}>">
<div class="tableform">
<div class="division">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
  <th><{t}>访问来源名称：<{/t}></th>
  <td><{input type="text" name="name" value=$settingInfo.name vtype="required"}><em><font color='red'>*</font></em></td>
</tr>
<{if $settingInfo.code }>
<tr>
  <th><{t}>标识：<{/t}></th>
  <td><{$settingInfo.code}><em><font color='red'>*</font></em></td>
</tr>
<{else}>
<tr>
  <th><{t}>标识：<{/t}></th>
  <td><{input type="text" name="code" value=$settingInfo.code vtype="required"}><em><font color='red'>*</font></em></td>
</tr>
<{/if}>
<tr>
    <th>接口调用私钥：</th>
    <td><{input type="text" name="interfacekey" value=$settingInfo.interfacekey vtype="required"}>&nbsp;<input type='button' value="随机生成私钥" onclick="genstr();" /><span style='margin-left:5px;'>用于数据接口调用时，签名验证的必要参数，请尽量设置成包含英文、数字、大小写的复杂格式</span></td>
</tr>
<tr>
  <th><{t}>访问权限：<{/t}></th>
  <td>
    <{foreach from=$configLists item=config key=key}>
        <h4><{$config.label}>：</h4>
        <div style="padding-left:15px;">
        <{foreach from=$config.methods item=method key=k}>
            <input type="checkbox" name="config[<{$key}>][]" value="<{$k}>" <{if $k|in_array:$settingInfo.config[$key]}>checked=checked<{/if}>/><label style='padding:0px 2px 0px 5px'><{$method}>(<{$k}>)</label>
        <{/foreach}>
        </div>
    <{/foreach}>  
  </td>
</tr>
<tr>
  <th><{t}>状态：<{/t}></th>
  <td>
    <input type="radio" name="status" value=1 <{if $settingInfo.status == 1}> checked<{/if}>>开启
    <input type="radio" name="status" value=0 <{if $settingInfo.status == 0}> checked<{/if}>>关闭<em><font color='red'>*</font></em>
  </td>
</tr>
</table>
</div>

<div class="table-action">
	<{button type="submit" id="btn-brand"  label="保存"}>
</div>

</form>
<script>

$('brandForm').store('target',{
    onRequest:function(){
       $('btn-brand').set('disabled', 'true');
    },
    onComplete:function(jsontext){
       var json = Json.evaluate(jsontext);
       if (typeof(json.error) != 'undefined'){
           $('btn-brand').set('disabled', '');
       }else{
           $('btn-brand').set('disabled', 'true');
           if(opener && opener.finderGroup && opener.finderGroup['<{$env.get.finder_id}>']){
              opener.finderGroup['<{$env.get.finder_id}>'].refresh.delay(400,opener.finderGroup['<{$env.get.finder_id}>']);
              window.close();
           }
       }
    }
});

<{if $env.get._finder_name}>
$('brandForm').store('target',{
    update:'messagebox'
});
<{/if}>

function genstr(){
    var len = 32;
    var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnoprstuvwxyz';
    var maxPos = chars.length;
    var pwd = '';
    for (i = 0; i < len; i++) {
        pwd += chars.charAt(Math.floor(Math.random() * maxPos));
    }
    $('brandForm').getElement("input[name='interfacekey']").set('value',pwd);
}
</script>
